﻿<UserControl 
    x:Class="ScrumFactory.Tasks.TaskSelector"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
    xmlns:props="clr-namespace:ScrumFactory.Tasks.Properties"
    xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
    xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition" 
    Background="#444444"
      IsHitTestVisible="True" Height="320" 
    BorderBrush="Gray" BorderThickness="0,1,0,0"       
    UseLayoutRounding="True" SnapsToDevicePixels="True"
    xmlns:SF_Helpers_Ext="clr-namespace:ScrumFactory.Windows.Helpers.Extensions;assembly=ScrumFactory.Windows.Helpers"
    x:Name="thisView">

    <Grid>

        <TextBlock             
            Text="{Binding TrackingTaskInfo}" Foreground="White" FontWeight="Normal" FontSize="{StaticResource BigFontSize}" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="12,3,0,0"/>

        <TextBlock 
                   Text="{x:Static props:Resources.Tasks}" 
                   Style="{StaticResource PanelMainTitle}" Opacity="0.5"
                   Foreground="White" Margin="0,-35,0,0" 
                   VerticalAlignment="Top" HorizontalAlignment="Right" />


        <ScrollViewer 
        VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
        ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Disabled">

            <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <ListBox   
                Grid.Column="0"
                Margin="10,25,10,0" 
                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                IsHitTestVisible="True"                                 
                Background="Transparent" 
                ItemContainerStyle="{StaticResource NoHorizontalLineDividedNoSelectionListBoxItem}"
                SF_Helpers:ItemActivation.ActivationMode="BothAndSingleClick"            
                SF_Helpers:ItemActivation.TheCommandToRun="{Binding TrackTaskCommand}"                                                
                ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"
                ItemsSource="{Binding FilteredTasks}">
                    <ListBox.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.Panel>
                                <ItemsPanelTemplate>
                                    <WrapPanel Orientation="Vertical" MaxHeight="280" HorizontalAlignment="Stretch" />
                                </ItemsPanelTemplate>
                            </GroupStyle.Panel>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>
                                    <TextBlock Margin="3,0,0,0" Text="{Binding Name}" Foreground="White" FontSize="{StaticResource SmallFontSize}"  />
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                        </GroupStyle>
                    </ListBox.GroupStyle>
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Orientation="Vertical" HorizontalAlignment="Stretch" MaxHeight="280" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <SF_Helpers:PixelBorder Margin="2,2,2,2" Cursor="Hand" Style="{StaticResource PostItBorder}" BorderThickness="2" CornerRadius="0" >
                                <Grid Width="240">

                                    <Image 
                                DataContext="{Binding HasArtifact}" Style="{StaticResource HasArtifactImage}" HorizontalAlignment="Right" VerticalAlignment="Top" />

                                    <Path Style="{StaticResource ClockPath_VM}" HorizontalAlignment="Center" VerticalAlignment="Center"/>

                                    <StackPanel Orientation="Vertical">
                                        <TextBlock
                                        Style="{StaticResource ItemTitleTextBlock}" FontSize="{StaticResource NormalFontSize}" 
                                        Text="{Binding Task.TaskName}"/>

                                        <DockPanel>

                                            <TextBlock Margin="0,0,0,0">
                                        <Hyperlink Command="{Binding DataContext.ShowTaskDetailCommand, ElementName=thisView}"
                                                   CommandParameter="{Binding .}" >
                                            <TextBlock Text="{x:Static props:Resources.Details}" FontSize="{StaticResource SmallFontSize}" />
                                        </Hyperlink>
                                    </TextBlock>

                                            <Image 
                                            DockPanel.Dock="Right" HorizontalAlignment="Right" Margin="3,0,0,0"
                                            DataContext="{Binding Task.TaskType}"  Style="{StaticResource TaskTypeOnPostItImage}"/>
                                        </DockPanel>

                                    </StackPanel>

                                    <!-- strange bind stuff go heres, but can not pass "me" as command parameter
                                cus somehow it messup the GC and "me" is never collected -->
                                    <DockPanel VerticalAlignment="Center" HorizontalAlignment="Right"                            
                                Style="{StaticResource ItemActionMenu}" >
                                        <Button 
                                            DockPanel.Dock="Left" VerticalAlignment="Center" Margin="0,0,5,0"
                                            Style="{StaticResource CleanButton}"
                                            Command="{Binding CopyTaskTrackIdCommand}" 
                                            ToolTip="{x:Static props:Resources.copy_track_info_to_clipboard}">
                                            <Image Source="/Images/Buttons/tag.png" Width="24" Height="24"/>
                                        </Button>
                                        <Button 
                                    HorizontalAlignment="Center" VerticalAlignment="Center"
                                    Style="{StaticResource CheckButton}"                                        
                                    Command="{Binding ShowFinishDialogCommand}"/>

                                    </DockPanel>


                                </Grid>

                            </SF_Helpers:PixelBorder >
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

                <TextBlock 
            Grid.Column="1" Margin="24,25,0,0" Opacity="0.5"
            Text="{x:Static props:Resources.take_one_task}" Foreground="White" FontWeight="Normal" FontSize="{StaticResource BigFontSize}" VerticalAlignment="Top" HorizontalAlignment="Left">
            <TextBlock.Style>
                <Style>                    
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding NotMineFilteredTasks.Count}" Value="0">
                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>
                </TextBlock>

                <ListBox   
                Grid.Column="1"
                Margin="20,50,10,0" 
                VerticalAlignment="Stretch" 
                IsHitTestVisible="True"                                 
                Background="Transparent" 
                ItemContainerStyle="{StaticResource NoHorizontalLineDividedNoSelectionListBoxItem}"                                                            
                ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"
                ItemsSource="{Binding NotMineFilteredTasks}">
                    <ListBox.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.Panel>
                                <ItemsPanelTemplate>
                                    <WrapPanel Orientation="Vertical" MaxHeight="280" HorizontalAlignment="Stretch" />
                                </ItemsPanelTemplate>
                            </GroupStyle.Panel>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>
                                    <TextBlock Margin="3,0,0,0" Text="{Binding Name}" Foreground="White" FontSize="{StaticResource SmallFontSize}"  />
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                        </GroupStyle>
                    </ListBox.GroupStyle>
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Orientation="Vertical" HorizontalAlignment="Stretch" MaxHeight="280" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <SF_Helpers:PixelBorder Margin="2,2,2,2" Cursor="Arrow" Style="{StaticResource PostItBorder}" BorderThickness="2" CornerRadius="0" >

                                <Grid Width="240">

                                    <Image 
                                DataContext="{Binding HasArtifact}" Style="{StaticResource HasArtifactImage}" HorizontalAlignment="Right" VerticalAlignment="Top" />

                                    <StackPanel Orientation="Vertical">
                                        <TextBlock
                                        Style="{StaticResource ItemTitleTextBlock}" FontSize="{StaticResource NormalFontSize}" 
                                        Text="{Binding Task.TaskName}"/>
                                        <DockPanel>
                                            <TextBlock Margin="0,0,0,0">
                                        <Hyperlink Command="{Binding DataContext.ShowTaskDetailCommand, ElementName=thisView}"
                                                   CommandParameter="{Binding .}" >
                                            <TextBlock Text="{x:Static props:Resources.Details}" FontSize="{StaticResource SmallFontSize}" />
                                        </Hyperlink>
                                    </TextBlock>
                                            <Image 
                                            DockPanel.Dock="Right" HorizontalAlignment="Right" Margin="3,0,0,0"
                                            DataContext="{Binding Task.TaskType}"  Style="{StaticResource TaskTypeOnPostItImage}"/>
                                        </DockPanel>
                                    </StackPanel>



                                    <DockPanel VerticalAlignment="Center" HorizontalAlignment="Right" Style="{StaticResource ItemActionMenu}" >
                                        <Button                                                                                                 
                                    VerticalAlignment="Top" HorizontalAlignment="Right"                               
                                    Style="{StaticResource CleanButton}" Margin="0,-10,0,0"
                                    Command="{Binding AssignTaskToMeCommand}"
                                    ToolTip="{x:Static props:Resources.assign_task_to_me}">
                                            <ContentControl Style="{StaticResource MemberImageNoIndicatorControlStyle}" DataContext="{Binding Model.SignedMemberUId, ElementName=thisView}"
                                        Width="32" Height="32"/>                                            
                                        </Button>
                                    </DockPanel>


                                </Grid>

                            </SF_Helpers:PixelBorder >
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

                <TextBlock 
            Grid.Column="0"
            Text="{x:Static props:Resources.no_tasks_for_you}" Margin="10,25,10,10" Foreground="White">
            <TextBlock.Style>
                <Style>
                    <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding FilteredTasks.Count}" Value="0">
                            <Setter Property="TextBlock.Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>
                </TextBlock>

            </Grid>


        </ScrollViewer>

        <ContentControl Style="{StaticResource LoadingAnimationContent}" />

    </Grid>
    
    
   
</UserControl>
